package com.seashop.feign.fallback;

import com.alibaba.fastjson.JSONObject;
import com.seashop.response.ResponseBase;
import com.seashop.vo.ProductSimpleVO;
import com.seashop.feign.ProductFeignClient;
import com.seashop.request.RecommendProductRequestParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @author moredln
 * @desc 产品服务调用失败处理
 * @date 2020-11-11 10:31
 */
@Component
@Slf4j
public class ProductFeignClientFallBack implements FallbackFactory<ProductFeignClient> {
    @Override
    public ProductFeignClient create(Throwable throwable) {
        return new ProductFeignClient(){
            @Override
            public ResponseBase listCategory(String countryCode, String languageType) {
                log.info("调用产品服务分类列表失败");
                return null;
            }

            @Override
            public ResponseBase listRecommendProductPage(RecommendProductRequestParam param) {
                log.info("调用产品服务分页推荐商品列表失败");
                return null;
            }

            @Override
            public JSONObject getExternProductDetail(String productId, String origin, String countryCode, String languageType, Long userId) {
                log.info("调用产品服务外部商品详情失败");
                return null;
            }

            @Override
            public List<ProductSimpleVO> queryProductSimpleInfoAndShare(Integer[] ids, String countryCode) {
                log.info("调用查询产品简单信息和分享值失败");
                return null;
            }

            @Override
            public List<ProductSimpleVO> queryProductSimpleInfo(Integer[] ids, String countryCode, String languageType) {
                log.info("调用查询产品简单信息失败");
                return null;
            }

            @Override
            public String queryDictionary(String text, String fromLanguageType, String toLanguageType) {
                log.info("调用产品服务查询字典表失败");
                return null;
            }
        };
    }
}
